﻿using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 纺织贸易管理系统;

namespace 后整理管理系统.新增窗体
{
    public partial class 测试结果 : Sunny.UI.UIForm
    {
        private TestData  Doc = new TestData ();
        public 测试结果(TestData testData )
        {
            InitializeComponent();
            Doc = testData;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Connect.dbcontext.Deleteable<TestData>(x => x.DocNum == Doc.DocNum && x.Color == Doc.Color && x.LotNo == Doc.LotNo && x.FabricName == Doc.FabricName).ExecuteCommand();
            Connect.dbcontext.Insertable(new TestData()
            {
                DocNum = Doc.DocNum,
                FabricName = Doc.FabricName,
                LotNo = Doc.LotNo,
                Color = Doc.Color,
                SeamSlippage = txtjiefenghuayi.Text,
                TearStrength = txtshilieqiangdu.Text,
                WaterproofEffect = txtfangshui.Text,
                Weight = txtchengpingkezhong.Text,
                Width = txtchengpingmenfu.Text,
                Divest = txttestboli.Text,
                Hydraulic = txttestshuiya.Text,
                MoisturePermeability = txttesttoushi.Text,
                Washing = txttestshuixi.Text,
                Wrinkling = txtqizhou.Text,
                Bubble = txtqipao.Text,
                Dedusting = txttuocheng.Text,
            }).ExecuteCommand();
            this.Close();
        }

        private void 测试结果_Load(object sender, EventArgs e)
        {
            if (Doc!=null) 
            {
                var testdata = Connect.dbcontext.Queryable<TestData>().First(x => x.DocNum == Doc.DocNum && x.Color == Doc.Color && x.LotNo == Doc.LotNo&&x.FabricName==Doc.FabricName );
                if (testdata != null)
                {
                    txtchengpingmenfu.Text = testdata.Width;
                    txtchengpingkezhong.Text = testdata.Weight;
                    txtjiefenghuayi.Text = testdata.SeamSlippage;
                    txtshilieqiangdu.Text = testdata.TearStrength;
                    txtfangshui.Text = testdata.WaterproofEffect;
                    txttestboli.Text = testdata.Divest;
                    txttestshuiya.Text = testdata.Hydraulic;
                    txttesttoushi.Text = testdata.MoisturePermeability;
                    txttestshuixi.Text = testdata.Washing;
                }
            }
        }
    }
}
